﻿/*
 ***************************************************************************
 * Microsoft Visual C# .NET
 * 名称：       App_Input_PersonTraiUpdForm
 * 类型：       控制层
 * 功能说明：   销售过程-人员特点维护页面
 * 作者：       黄鑫
 * 创建日期：   2007/09/27
 * 修改日期     修改者      修改内容
 * 
 * 
 * ---
 ***************************************************************************
*/
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shpm.System.Validator;
using Shpm.System.Web.Control;
using log4net;
using Shpm.App.Input.Bean;
using Shpm.App.Input.Dao;
using Shpm.App.Commons.Db.Beans.Master;
using Shpm.System;
using Shpm.App.Commons.Utils;

public partial class App_Input_PersonTraitUpdForm : System.Web.UI.Page
{
    // log
    protected static ILog log = LogManager.GetLogger(typeof(App_Input_PersonTraitUpdForm));


    #region // page load
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            this.ViewState["PROC_ID"] =  Context.Items["SALE_PROC_ID"] ;
            SaleProcessDao dao = new SaleProcessDao();
            SaleProcessBean beanSP = new SaleProcessBean();
            beanSP.SaleProcId = Convert.ToInt32(ViewState["PROC_ID"]);
            beanSP = dao.FindBySaleProcess(beanSP);
            this.ViewState["CANCEL_FLG"] = beanSP.CancelFlg;
            this.ViewState["CUR_STEP"] = beanSP.CurrentStep;
        }

    }
    #endregion

    #region// 登记按钮
    protected void btnOk_Click(object sender, EventArgs e)
    {
        try
        {
            // do validate check
            ComValidateChecker vd = new ComValidateChecker();
            if (!vd.DoValidator())
            {
                ((Design_MasterPage)this.Master).InfoMessage = vd.ErrorMessage;
                return;
            }
            SaleProcessBean bean = new SaleProcessBean();
            SaleProcessDao dao = new SaleProcessDao();
            bean.SaleProcId = Convert.ToInt32(this.ViewState["PROC_ID"]);
            bean.FamilyMemo = txtMemo.Text;
            bean.FamilyParticularity = txtParticularity.Text;
            bean.FamilyPet = txtPet.Text;
            bean.FamilyTrait = txtTrait.Text;
            dao.UpdSaleProcFamily(bean);
            ((Design_MasterPage)this.Master).InfoMessage =
                HttpContext.GetGlobalResourceObject(Constants.GLOBAL_RESOURCE_NAME, "I0002").ToString();
        }
        catch (Exception ex)
        {
            log.Fatal(ex.StackTrace);
            log.Fatal(ex.Message);
            throw ex;
        }

    }
    #endregion

    #region// 返回按钮
    protected void btnBack_Click(object sender, EventArgs e)
    {
    }
    #endregion

    #region lnkTabCommand
    protected void lnkTab_Command(object sender, CommandEventArgs e)
    {
        string directUrl = "~/App/Input/SaleProcesseMembershipForm.aspx";
        switch (e.CommandName)
        {
            case "btn0":
                // 新建洽谈
                directUrl = "~/App/Input/SaleProcessBeginForm.aspx";
                break;
            case "btn1":
                // 销售管理
                Context.Items["RIGHT"] = "true";
                directUrl = "~/App/Input/SaleCountForm.aspx";
                break;
            case "btn2":
                // 入住管理
                directUrl = "~/App/Input/SaleProcesseMembershipForm.aspx";
                break;
            case "btn3":
                // 购卡管理
                directUrl = "~/App/Input/RightPersonForm.aspx";
                break;
            case "btn4":
                // 客户移交
                directUrl = "~/App/Input/ContractHabitationForm.aspx";
                break;
            case "btn2_1":
                // 主会员信息
                directUrl = "~/App/Input/MemberForm.aspx";
                break;
            case "btn2_2":
                // 副会员信息
                directUrl = "~/App/Input/ViceMemberForm.aspx";
                break;
            case "btn2_3":
                // 陪住人信息
                directUrl = "~/App/Input/AccompanyForm.aspx";
                break;
            case "btn2_4":
                // 体检报告
                directUrl = "~/App/Input/SaleProcessHealthForm.aspx";
                break;
            case "btn2_5":
                // 审核
                directUrl = "~/App/Input/SaleProcessIndefinForm.aspx";
                break;
            case "btn2_6":
                // 入住合同
                directUrl = "~/App/Input/ContractHabitationForm.aspx";
                break;
            case "btn2_7":
                // 特点
                return;
            case "btn6":
                // 资格审核
                directUrl = "~/App/Input/SaleProcessIndefinForm.aspx";
                break;
                default:
                break;
        }
        if (!string.IsNullOrEmpty(Convert.ToString(this.ViewState["PROC_ID"])))
        {
            Context.Items["SALE_PROC_ID"] = this.ViewState["PROC_ID"];
        }
        ControllerUtils.Transfer(this.Context, directUrl, false);

    }
    #endregion

    #region lnkClick
    // link 按钮 click
    protected void lnkBtn_Command(object sender, CommandEventArgs e)
    {
        string directUrl = "~/App/Search/SaleProcSrhForm.aspx";
        switch (e.CommandName)
        {
            case "btn0":
                // 销售开始                
                directUrl = "~/App/Input/SaleProcessBeginForm.aspx";
                break;
            case "btn1":
                // 入会登记
                directUrl = "~/App/Input/SaleProcesseMembershipForm.aspx";
                break;
            case "btn2":
                // 体检报告
                directUrl = "~/App/Input/SaleProcessHealthForm.aspx";
                break;
            case "btn3":
                // 资格审核
                directUrl = "~/App/Input/SaleProcessIndefinForm.aspx";
                break;
            case "btn4":
                // 合同签订
                directUrl = "~/App/Input/SaleContractForm.aspx";
                break;
            case "btn5":
                // 费用缴纳
                directUrl = "~/App/Input/PaymentUpdForm.aspx";
                break;
            case "btn6":
                // 礼品发放
                directUrl = "~/App/Search/SaleProcSrhForm.aspx";
                break;
            case "btn7":
                // 完成
                directUrl = "~/App/Search/SaleProcSrhForm.aspx";
                break;
            default:
                break;
        }
        if (!string.IsNullOrEmpty(Convert.ToString(this.ViewState["PROC_ID"])))
        {
            Context.Items["SALE_PROC_ID"] = this.ViewState["PROC_ID"];
        }
        ControllerUtils.Transfer(Context, directUrl, true);
    }
    #endregion

    #region PreRender
    void Page_PreRender(object sender, EventArgs e)
    {
        // 销售过程跟踪 link 状态
        SaleProcessBean bean = new SaleProcessBean();
        SaleProcessDao dao = new SaleProcessDao();
        bean.SaleProcId = Convert.ToInt32(this.ViewState["PROC_ID"]);
        bean = dao.FindBySaleProcess(bean);
        if (bean != null)
        {
            txtTrait.Text = bean.FamilyTrait;
            txtPet.Text = bean.FamilyPet;
            txtParticularity.Text = bean.FamilyParticularity;
            txtMemo.Text = bean.FamilyMemo;
        }
        else
        {
            txtTrait.Text = "";
            txtParticularity.Text = "";
            txtPet.Text = "";
            txtMemo.Text = "";
        }
    }
    #endregion

}
